<template>
    <div class="r-item c-title-5">
    <template v-if="!item.isTips">
        <span>{{ item.ago }}</span>
        <span class="c-coin">{{ getName }}</span>
        <JNumber :num="getNum" :is-color="true" :suffix="isPercent ? '%' : ''"></JNumber>
    </template>
    <template v-else>
       <span class="tips">{{ item.title }}</span>
    </template>
    </div>
</template>

<script lang="ts" setup>
import { reactive, ref, computed, onMounted } from "vue";
import { uuidCreate } from "@/comm/uuid";
import { get } from "@/comm/request";
import { URL_SCROLL_NEWS } from "@/comm/api";
import { formatTimeAgo } from "@/comm/format";
import JNumber from "@/components/j-number/index.vue";
import i18n from "@/locals";

const props = defineProps({
    item: {
        type: Object,
        required: true
    }
});

const isPercent = ref(false);

const getNum = computed(() => {
    let type = props.item.eventType;
    if (type == "hot") {
        isPercent.value = false;
        return props.item.volume;
    }

    //波动率
    if (type == "volatility") {
        isPercent.value = false;
        return props.item.volatility;
    }

    if (type == "bigAmount") {
        isPercent.value = false;
        return props.item.outAmount || props.item.inAmount;
    }

    isPercent.value = true;
    return props.item.priceChangePercent;
});

const getName = computed(() => {
    let type = props.item.eventType;
    if (type == "bigAmount") {
        if (props.item.outSymbol) {
            return i18n.global.t("message.Temp.a").concat(props.item.outSymbol);
            // return "大额转出" + props.item.outSymbol;
        }
        return i18n.global.t("message.Temp.b").concat(props.item.outSymbol);
        // return "大额转入" + props.item.inSymbol;
    }
    return props.item.symbol;
});
</script>

<style lang="less" scoped>
.c-coin {
    margin: 0 12px;
    color: #fff;
}
.r-item{
    cursor: pointer;
}
.tips{
    font-weight: 700;
    color: var(--lose);
}
</style>
